<?php

namespace App\Models\Admin;

use App\Models\Base;

class AdminMenu extends Base
{

    /**
     * @var string $tableName 指定表名
     */
    protected $tableName = 'es_admin_menu';


    /**
     * 编辑菜单
     */
    public function edit(array $param)
    {
        $where = [];
        if ($id = $param['id'] ?? '') $where['id'] = $id;

        $data = [];
        if ($manuName = $param['menu_name'] ?? '') $data['menu_name'] = $manuName;
        if (isset($param['path'])) $data['path'] = $param['path'];
        if (isset($param['pid'])) $data['pid'] = $param['pid'];
        if (isset($param['node_ids'])) $data['node_ids'] = $param['node_ids'];
        if (isset($param['sort'])) $data['sort'] = $param['sort'];

        if (!$where || !$data) return true;
        return self::create() -> where($where) -> update($data);
    }

}